import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import MyFooter from './components/MyFooter'
import MyHeader from './components/MyHeader'
import Fixed from './components/Fixed'
// 引入axios第三方插件并配置添加至Vue原型对象中
import axios from 'axios'
// 因为采用了http代理的方式所以不再需要使用axios发送请求，也就不用配置axios的默认请求路径
axios.defaults.baseURL = 'http://127.0.0.1:5050/v1'
Vue.prototype.axios = axios;

// 引入element-ui组件库并进行配置
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI);


Vue.config.productionTip = false
Vue.component("my-footer", MyFooter);
Vue.component("my-header", MyHeader);
Vue.component("my-fixed", Fixed);
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app');


//main.js里面的代码
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面meta */
  /* if (to.meta.content) {
    let head = document.getElementsByTagName('head');
    let meta = document.createElement('meta');
    meta.content = to.meta.content;
    head[0].appendChild(meta)
  } */
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next()
});
